﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class User_ReaderChangeInfo : System.Web.UI.Page
{
    public string Loginname, readerID, readerName, readerClass, readerCreateTime, remarks, sex, Telphone, Email, Birthday;
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (Session["userName"] != null)
        {
            SQL sql = new SQL();
            Loginname = sql.getDataFormTable("ReaderID", "reader_info", "readerid", Session["userName"].ToString(), "", "", "", "", 1);
            readerID = Session["userName"].ToString();
            readerName = sql.getDataFormTable("ReaderName", "reader_info", "readerid", Session["userName"].ToString(), "", "", "", "", 1);
            sex = sql.getDataFormTable("sex", "reader_info", "readerid", Session["userName"].ToString(), "", "", "", "", 1);
            readerClass = sql.getDataFormTable("ClassID", "reader_info", "readerid", Session["userName"].ToString(), "", "", "", "", 1);
            readerCreateTime = sql.getDataFormTable("CreateDate", "reader_info", "readerid", Session["userName"].ToString(), "", "", "", "", 1);
            remarks = sql.getDataFormTable("remarks", "reader_info", "readerid", Session["userName"].ToString(), "", "", "", "", 1);
            Telphone = sql.getDataFormTable("Telphone", "reader_info", "readerid", Session["userName"].ToString(), "", "", "", "", 1);
            Email = sql.getDataFormTable("Email", "reader_info", "readerid", Session["userName"].ToString(), "", "", "", "", 1);
            Birthday = sql.getDataFormTable("Birthday", "reader_info", "readerid", Session["userName"].ToString(), "", "", "", "", 1);

        }
        if (!IsPostBack)
        {
            i1.Text = Email;
            i2.Text = Telphone;
            i3.Text = string.Format("{0:yyyyMMdd}", Birthday);
           
        }
       
    }
    protected void Button1_Click(object sender, EventArgs e)
    {

    
        SQL sql = new SQL();
        try
        {
            sql.setDataIntoTable("Reader_info", "Email", "", i1.Text, "readerID", Session["userName"].ToString());
        }
        catch (System.Exception ex)
        {
            Label1.Text = "邮箱有误";
        }
        try
        {
            sql.setDataIntoTable("Reader_info", "Telphone", "", i2.Text, "readerID", Session["userName"].ToString());
        }
        catch (System.Exception ex)
        {
            Label1.Text = "号码有误";
        }
        try
        {
            sql.setDataIntoTable("Reader_info", "Birthday", "", i3.Text, "readerID", Session["userName"].ToString());
            Response.Write("<script language=javascript>alert('修改成功');window.location = 'UserIndex.aspx';</script>");
        }
        catch (System.Exception ex)
        {
            Label1.Text = "日期有误";

        }
    }
}